'use strict';
/**
 * @params {表单数据}
 * @bussiness {注册}
 * @author JC
 * @date 2022-08-15
 * **/
const Service = require('egg').Service;

class Register extends Service {
    async getRegister (params) {
        // 查找是否重复数据
        let check = await this.app.mysql.get('user', params) // 根据邮箱去数据库查找是否重复
        if(!check) {
            let result = await this.app.mysql.insert('register', params)
            return {
                success:'注册成功',
                code:200,
                data:result
            }
        }else {
            return {
                error:'用户已存在！请直接登录',
                code:400,
                data:check
            }
        }
    }
}
module.exports = Register